package com.utils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.*;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/5/4 0:07
 * @since JDK 1.8
 *
 * sql 查询工具类
 */
public class DBSql {

    private static Connection getConnection(){
        return new ConnectionUtils().getSysTemConnection();
    }

    //执行查询sql
    private static ResultSet sqlExecuteQuery(String sql){
        Statement stmt = null;
        Connection conn = null;
        ResultSet rs=null;
        try {
            conn=getConnection();
            stmt = conn.createStatement();
            rs = stmt.executeQuery(sql);
        }catch (Exception e){
            e.printStackTrace();
        }
        return rs;
    }

    /**
     * sql 执行
     * @param sql
     * @return
     */
    private static boolean sqlExecute(String sql){
        boolean flag=false;
        Statement stmt = null;
        Connection conn = null;
        try {
            conn=getConnection();
            stmt = conn.createStatement();
            flag = stmt.execute(sql);
        }catch (Exception e){
            e.printStackTrace();
        }
        return flag;
    }


    //获取字段列表
    private static String[] getFeildList(ResultSet rs){
        try {
            ResultSetMetaData rsmd = rs.getMetaData();
            String [] lie=new String[rsmd.getColumnCount()];
            for (int i = 1; i <rsmd.getColumnCount()+1; i++) {
                lie[i-1]=rsmd.getColumnName(i);
            }
            return lie;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }






    public static void main(String[] args) {

        System.out.println(Math.sqrt(16));   //4.0
        System.out.println(Math.cbrt(8));    //2.0
        System.out.println(Math.pow(3,2));     //9.0


       List<Integer> integerList=new ArrayList<>();
        for (int i = 0; i <=10; i++) {
            integerList.add(i);
        }
        Collections.shuffle(integerList);
        integerList.stream().forEach(e->{
            System.out.println(e);
        });
        Map<String, Object> objectMap=new HashMap<>();
        Iterator<Map.Entry<String, Object>> entryIterator=objectMap.entrySet().iterator();
        while (entryIterator.hasNext()){
            Map.Entry<String, Object> objectEntry=entryIterator.next();
            objectEntry.getKey();
            objectEntry.getValue();
        }
    }







}
